home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 40
/
Amiga Format CD40 (1999-05-11)(Future Publishing)(GB)(Track 1 of 3)[!][issue 1999-06].iso
/
-readerstuff-
/
paul_qureshi
/
source
/
nbody.lzx
/
NBody_Collision_Detection
/
project
/
cylinder.c
< prev
next >
Wrap
C/C++ Source or Header
|
1999-03-27
|
1KB
|
50 lines
#include <stdio.h>
#include <math.h>
#define PI 3.141592653589793
main()
{
int n, m, i=0; /* loop counter */
double x, y, z; /* coordinates */
FILE *fpr;
fpr = fopen("cylinder.dat", "w");
fprintf(fpr, "polyhedron cylinder\n");
fprintf(fpr, "n0 0 0 2.01\n");
for(m=0; m<32; m++) {
x = 2*cos(m*PI/16.0);
y = 2*sin(m*PI/16.0);
z = 2;
fprintf(fpr, "n01.m%02d %2.14f %2.14f %2.14f\n", m,x,y,z);
}
for(m=0; m<32; m++) {
x = 2*cos(m*PI/16.0);
y = 2*sin(m*PI/16.0);
z = -2;
fprintf(fpr, "n02.m%02d %2.14f %2.14f %2.14f\n", m,x,y,z);
}
fprintf(fpr, "n3 0 0 -2.01\n");
fprintf(fpr, "*\n");
for (m=0; m<32; m++)
fprintf(fpr, "f%03d n0 n01.m%02d n01.m%02d\n",i++, m, (m+1)%32);
for(m=0; m<32; m++) {
fprintf(fpr, "f%03d n02.m%02d n02.m%02d n01.m%02d n01.m%02d\n",i++, m, (m+1)%32, (m+1)%32, m);
}
for (m=0; m<32; m++)
fprintf(fpr, "f%03d n3 n02.m%02d n02.m%02d\n",i++, (m+1)%32, m);
fprintf(fpr, "*\n");
fclose(fpr);
}